package com.fulihui.information.biz.conv;

import com.fulihui.information.dal.dataobj.InfoContentCommentsPraise;
import com.fulihui.information.dto.InfoContentCommentsPraiseDTO;

import java.util.List;
import java.util.stream.Collectors;

import static java.util.Collections.emptyList;
import static org.springframework.util.CollectionUtils.isEmpty;

/**
 * Created by LM on 2017/4/17.
 */
public class ContentCommentsPraiseConv {

    public static InfoContentCommentsPraiseDTO toDTO(InfoContentCommentsPraise entity) {
        if (entity == null) {
            return null;
        }
        InfoContentCommentsPraiseDTO dto = new InfoContentCommentsPraiseDTO();
        dto.setUserId(entity.getUserId());
        dto.setCommentId(entity.getCommentId());
        dto.setContentId(entity.getContentId());
        dto.setGmtCreate(entity.getGmtCreate());
        return dto;
    }

    public static List<InfoContentCommentsPraiseDTO> toDTOList(List<InfoContentCommentsPraise> list) {
        if (isEmpty(list)) {
            return emptyList();
        }
        return list.stream().map(it -> toDTO(it)).collect(Collectors.toList());
    }

}
